<!-- 投标申请 -投标部门负责人 -->
<template>
	<view class="page">
		
		<u--form
			class="basic-style"
			labelPosition="top"
			:model="basicForm"
			ref="form1"
			labelWidth="auto"
			:labelStyle="{
				fontSize: '14px',
				color: '#B2B2B2',
				lineHight: '20px'
			}"
		>
			<!-- <view class="basic-title basic-border">基础信息</view> -->
			<u-form-item
				label="单据编号"
				prop="tenderCode"
				:borderBottom="false"
				ref="item1"
			>
				<u--input
					disabled
					placeholder="请选择单据编号"
					v-model="basicForm.tenderCode"
					border="surround"
					suffixIcon="calendar-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
				></u--input>
			</u-form-item>
			<u-form-item
				label="创建日期"
				prop="createTime"
				:borderBottom="false"
				ref="item1"
			>
				<u--input
					disabled
					placeholder="请选择创建日期"
					v-model="basicForm.createTime"
					border="surround"
					suffixIcon="calendar-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
				></u--input>
			</u-form-item>
			<!-- v-if="basicForm.applyType && basicForm.applyType == 2" -->
			<u-form-item
			v-if="basicForm.applyType == 2"
				label="关联投标档案"
				prop="tenderFinalId_dictText"
				:borderBottom="false"
				ref="item1"
			>
				<u--input
					v-model="basicForm.tenderFinalId_dictText"
					disabled
					placeholder="请输入关联投标档案"
					border="surround"
				></u--input>
			</u-form-item>
			<u-form-item
				label="申请人"
				prop="proposer_dictText"
				:borderBottom="false"
				ref="item1"
			>
				<u--input
					v-model="basicForm.proposer_dictText"
					disabled
					placeholder="请选择经办人"
					border="surround"
					suffixIcon="arrow-down-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
				></u--input>
			</u-form-item>
			<u-form-item
				label="申请部门"
				prop="proposerDeptId_dictText"
				:borderBottom="false"
				ref="item1"
			>
				<u--input
					v-model="basicForm.proposerDeptId_dictText"
					disabled
					placeholder="请选择经办部门"
					border="surround"
					suffixIcon="arrow-down-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
				></u--input>
			</u-form-item>
			<u-form-item
				label="项目名称"
				prop="projectName"
				:borderBottom="false"
				ref="item1"
				required
			>
				<u--input
					disabled
					placeholder="请选择项目名称"
					v-model="basicForm.projectName"
					border="surround"
					suffixIcon="arrow-down-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
				></u--input>
			</u-form-item>
			<u-form-item
				label="承接人"
				prop="undertaker_dictText"
				:borderBottom="false"
				ref="item1"
				required
			>
				<u--input
					v-model="basicForm.undertaker_dictText"
					placeholder="请选择承接人"
					border="surround"
					disabled
					suffixIcon="arrow-down-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
				></u--input>
			</u-form-item>
			<u-form-item
				
				label="业绩归属年度"
				prop="year"
				:borderBottom="false"
				ref="item1"
				required
			>
				<u--input
					v-model="basicForm.year"
					disabled
					placeholder="请选择业绩归属年度"
					border="surround"
					suffixIcon="arrow-down-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
				></u--input>
			</u-form-item>
			<u-form-item
				label="项目地址"
				prop="projectAddress"
				:borderBottom="false"
				ref="item1"
			>
				<h-select-address-input
					style="width: 100%"
					v-model="basicForm.projectAddress"
					disabled
					placeholder="请选择项目地址"
					border="surround"
					suffixIcon="arrow-down-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
				></h-select-address-input>
			</u-form-item>
			<u-form-item
				label="项目详细地址"
				prop="detailedAddress"
				:borderBottom="false"
				ref="item1"
			>
				<u--input
					v-model="basicForm.detailedAddress"
					disabled
					placeholder="请填写详细项目地址"
					border="surround"
				></u--input>
			</u-form-item>
			
			<u-form-item
				v-if="basicForm.businessTeam_dictText"
				label="经营团队"
				prop="businessTeam_dictText"
				:borderBottom="false"
				ref="item1"
				required
			>
				<u--input
					v-model="basicForm.businessTeam_dictText"
					disabled
					placeholder="请选择经营团队"
					border="surround"
					suffixIcon="arrow-down-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
				></u--input>
			</u-form-item>
			<u-form-item
				v-else
				label="经营团队"
				prop="businessTeam"
				:borderBottom="false"
				ref="item1"
				required
			>
				<u--input
					v-model="basicForm.businessTeam"
					disabled
					placeholder="请选择经营团队"
					border="surround"
					suffixIcon="arrow-down-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
				></u--input>
			</u-form-item>
			
			<u-form-item
				v-if="basicForm.ownerUnit_dictText"
				label="业主单位"
				prop="ownerUnit_dictText"
				:borderBottom="false"
				ref="item1"
				required
			>
				<u--input
					v-model="basicForm.ownerUnit_dictText"
					disabled
					placeholder="请选择业主单位"
					border="surround"
					suffixIcon="arrow-down-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
				></u--input>
			</u-form-item>
			<u-form-item
				v-else
				label="业主单位"
				prop="ownerUnit"
				:borderBottom="false"
				ref="item1"
				required
			>
				<u--input
					v-model="basicForm.ownerUnit"
					disabled
					placeholder="请选择业主单位"
					border="surround"
					suffixIcon="arrow-down-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
				></u--input>
			</u-form-item>
			
			<u-form-item
				v-if="basicForm.ownerLinkman_dictText"
				label="业主联系人"
				prop="ownerLinkman_dictText"
				:borderBottom="false"
				ref="item1"
				required
			>
				<u--input
					v-model="basicForm.ownerLinkman_dictText"
					disabled
					placeholder="请选择业主联系人"
					border="surround"
					suffixIcon="arrow-down-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
				></u--input>
			</u-form-item>
			<u-form-item
				v-else
				label="业主联系人"
				prop="ownerLinkman"
				:borderBottom="false"
				ref="item1"
				required
			>
				<u--input
					v-model="basicForm.ownerLinkman"
					disabled
					placeholder="请选择业主联系人"
					border="surround"
					suffixIcon="arrow-down-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
				></u--input>
			</u-form-item>
			
			<u-form-item
				label="业主联系方式"
				prop="ownerTel"
				:borderBottom="false"
				ref="item1"
				required
			>
				<u--input
					v-model="basicForm.ownerTel"
					disabled
					placeholder="请填写业主联系方式"
					border="surround"
				></u--input>
			</u-form-item>
			<u-form-item
				label="报名截止时间"
				prop="entriesEndDate"
				:borderBottom="false"
				ref="item1"
			>
				<h-time-select
					v-model="basicForm.entriesEndDate"
					placeholder="请选择报名截止时间"
					border="surround"
					suffixIcon="calendar-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
					mode="datetime"
				></h-time-select>
			</u-form-item>
			<u-form-item
				label="投标截止时间"
				prop="tenderEndDate"
				:borderBottom="false"
				ref="item1"
			>
				<h-time-select
					v-model="basicForm.tenderEndDate"
					placeholder="请选择投标截止时间"
					border="surround"
					suffixIcon="calendar-fill"
					:suffixIconStyle="{color: '#B2B2B2'}"
					mode="datetime"
				></h-time-select>
			</u-form-item>
			
			<u-form-item
				label="招标方式"
				prop="biddingMethod"
				:borderBottom="false"
				ref="item1"
				required
			>
				<h-dict-select
					disabled
					style="width: 100%" 
					v-model="basicForm.biddingMethod" 
					placeholder="请选择招标方式" 
					dictName="bidding_method" 
					suffixIcon="arrow-down-fill" 
					:suffixIconStyle="{color: '#B2B2B2'}"
				></h-dict-select>
			</u-form-item>
			<u-form-item
				label="投标控制价(元)"
				prop="controlPrice"
				:borderBottom="false"
				ref="item1"
			>
				<h-money-input
					placeholder="请填写招标控制价"
					v-model="basicForm.controlPrice"
				></h-money-input>
			</u-form-item>
			<u-form-item
				label="标书费(元)"
				prop="entryFee"
				:borderBottom="false"
				ref="item1"
			>
				<h-money-input
					placeholder="请填写标书费"
					v-model="basicForm.entryFee"
				></h-money-input>
			</u-form-item>
			<u-form-item
				label="投标保证金(元)"
				prop="tenderBond"
				:borderBottom="false"
				ref="item1"
			>
				<h-money-input
					placeholder="请填写投标保证金"
					v-model="basicForm.tenderBond"
				></h-money-input>
			</u-form-item>
			<u-form-item
				label="项目公示信息"
				prop="projectPublicity"
				:borderBottom="false"
				ref="item1"
			>
				<u--textarea disabled confirmType="done" v-model="basicForm.projectPublicity" placeholder="请填写项目公示信息" ></u--textarea>
			</u-form-item>
			<u-form-item
				label="投标内容摘要"
				prop="tenderContent"
				:borderBottom="false"
				ref="item1"
			>
				<u--textarea disabled confirmType="done"  v-model="basicForm.tenderContent" placeholder="请填写投标内容摘要" ></u--textarea>
			</u-form-item>
			
		</u--form>
		
		<!-- 附件 -->
		<view class="basic-style">
			<view class="basic-title basic-border">招标文件</view>
			<!-- <file-list :fileList="basicForm.attachment" style="padding-top:16rpx"></file-list> -->
			<view class="" style="width: 100%;">
				<!-- <h-upload-file v-model="basicForm.xgfj" :isIcon="false"></h-upload-file> -->
				<file-list v-if="basicForm.tenderFile" v-model="basicForm.tenderFile"></file-list>
			</view>
		</view>
		
		<view class="basic-style">
			<view class="basic-title basic-border">投标单位信息</view>
			
			<u--form
				labelPosition="top"
				:model="basicForm"
				ref="form1"
				labelWidth="auto"
				:labelStyle="{
					fontSize: '14px',
					color: '#B2B2B2',
					lineHight: '20px'
				}"
			>
				<u-form-item
					label="投标部门"
					prop="tenderDept"
					:borderBottom="false"
					ref="item1"
					required
				>
					<h-select-depart-input
						disabled
						v-model="basicForm.tenderDept"
						:departName="basicForm.tenderDept_dictText"
						placeholder="请选择投标部门"
						border="surround"
						style="width: 100%;"
						suffixIcon="arrow-down-fill"
						:suffixIconStyle="{color: '#B2B2B2'}"
						@detail="ontenderDeptDetail"
					></h-select-depart-input>
				</u-form-item>
				<u-form-item
					label="投标编制人"
					prop="tenderPerson"
					:borderBottom="false"
					ref="item1"
					required
				>
					<h-select-person-input 
						style="width: 100%"
						v-model="basicForm.tenderPerson"
						placeholder="请选择投标编制人"
						border="surround"
						suffixIcon="arrow-down-fill"
						:suffixIconStyle="{color: '#B2B2B2'}"
						objectField="basicForm.tenderPerson"
						@detail="onManagerTrusteeDetail"
					></h-select-person-input>
				</u-form-item>
				<u-form-item
					label="投标单位"
					prop="tenderUnit_dictText"
					:borderBottom="false"
					ref="item1"
					required
				>
					<u--input
						v-model="basicForm.tenderUnit_dictText"
						disabled
						placeholder="请选择投标单位"
						border="surround"
						suffixIcon="arrow-down-fill"
						:suffixIconStyle="{color: '#B2B2B2'}"
					></u--input>
				</u-form-item>
				<u-form-item
					label="是否需要协调"
					prop="needHelp"
					:borderBottom="false"
					ref="item1"
				>
					<h-dict-radio disabled v-model="basicForm.needHelp" dictName="YES_OR_NO"></h-dict-radio>
				</u-form-item>
				<u-form-item
					v-if="basicForm.needHelp && basicForm.needHelp == 1"
					label="协同人员（多选）"
					prop="helperIds_dictText"
					:borderBottom="false"
					ref="item1"
				>
					<u--input
						v-model="basicForm.helperIds_dictText"
						disabled
						placeholder="请选择协同人员（多选）"
						border="surround"
						suffixIcon="arrow-down-fill"
						:suffixIconStyle="{color: '#B2B2B2'}"
					></u--input>
				</u-form-item>
				<u-form-item
					label="备注"
					prop="remarks"
					:borderBottom="false"
					ref="item1"
				>
					<u--textarea confirmType="done" disabled v-model="basicForm.remarks" placeholder="请输入备注" ></u--textarea>
				</u-form-item>
			</u--form>
			
		</view>
		<view class="basic-style">
			<view class="basic-title basic-border">业务分类</view>
			<view 
				v-if="getManagerPlanList && getManagerPlanList.length" 
				
			>
				<view 
					v-for="(item, index) in getManagerPlanList" 
					class="inforamtion"
					style="display: flex;" 
					:key="index">
					<view>
						<view class="option" style="width: 520rpx;">
							<view class="lf">业务分类</view>
							<view class="rl">{{ item.serviceType }}</view>
						</view>
						<view class="option" style="width: 520rpx;">
							<view class="lf">业务名称</view>
							<view class="rl">{{ item.serviceName }}</view>
						</view>
					</view>
				</view>
			</view>
			<view v-else>
				<u-empty
				        mode="data"
				        icon="/static/empty/data.png"
				>
				</u-empty>
			</view>
			
		</view>
		
		<view class="space-x-1 px-1 btn_position">
			<backButton  @onSubmit="onSubmit" :nodeObj="nodeObj" :model="model" :resultObj="resultObj"></backButton>
		</view>
		<view style="height: 100rpx;"></view>
		
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
import fileList from './components/fileList.vue'
import backButton from '@/components/backButton.vue'
import {
		queryByIdTender, // 根据id查询信息
		queryByIdTenderService, // 业务列表
		getProcessTaskTransInfo, // 流程流转
		erpOmcTenderEdit // 编辑
		
	} from '@/api/index.js'
	import {
		BASE_URL
	} from '@/utils/baseUrl.js'
export default {
	components: {
		fileList,
		backButton
	},
	data() {
		return {
			resultObj: {}, // 流程图流转信息
			isSubmit: false, // 是否点击提交
			nodeObj: {},
			dataNodeObj: '',
			tabvalue: '',
			
			id: '', // 详情id值
			basicForm: {},
			model: {},
			getManagerPlanList: [], // 业务列表
			
		};
	},
	onLoad(options) {
		var that = this
		this.model = JSON.parse(decodeURIComponent(options.item))
		// #ifdef APP-NVUE
			var eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
		// #endif
		// #ifndef APP-NVUE
			var eventChannel = this.getOpenerEventChannel();
		// #endif
		// 监听sendMessage事件，获取上一页面通过eventChannel传送到当前页面的数据
		eventChannel.on('sendMessage', function(data) {
			that.tabvalue = data.tabvalue
			that.nodeObj = JSON.parse(decodeURIComponent(data.nodeObj))
			that.dataNodeObj = data.nodeObj
			that.loadData(that.nodeObj.dataId)
			that.id = that.nodeObj.dataId
			that.getErpOmcContractManagerPlanList() // 开票信息列表
			that.getProcessTaskTrans(that.model.id)
		})
	},
	onReady() {
		// 修改标题
		uni.setNavigationBarTitle({
			title: this.model.bpmBizTitle.replace(/(【|】)/g,'')
		});
	},
	methods: {
		loadData(id){
			queryByIdTender({ id }).then(res => {
				if(res.success){
					this.basicForm = res.result
				} else {
					this.$refs.uToast.show({
						message: res.message,
						type: 'error'
					})
				}
			})
		},
		
		// 获取业务列表
		getErpOmcContractManagerPlanList () {
			var params = {
				id: this.id
			}
			queryByIdTenderService (params).then(res => {
				if (res.success) {
					this.getManagerPlanList = res.result || []
				} else {
					this.$refs.uToast.show({
						message: res.message,
						type: 'error'
					})
				}
			})
		},
		
		// 投标部门详情
		ontenderDeptDetail (item) {
			var title = ''
			if (item && item.length) {
				item.map((value, index) => {
					title = value.departName + ',' + title
					
				})
				title = title.substring(0, title.lastIndexOf(','))
			}
			this.basicForm.tenderDept_dictText = title
		},
		
		// 选择投标编制人详情
		onManagerTrusteeDetail (item) {
			var title = ''
			title = item.realname
			this.basicForm.tenderPerson_dictText = title
		},
		
		// 查询流程流转信息 -- 获取下一节点信息
		getProcessTaskTrans(taskId){
			getProcessTaskTransInfo({ taskId }).then(res => {
				if(res.success){
					this.resultObj = res.result
				} else {
					this.$refs.uToast.show({
						message: res.message,
						type: 'error'
					})
				}
			}).catch(err => {
				console.log(err);
			})
		},
		
		// 点击提交
		onSubmit () {
			var _this = this
			if (!this.basicForm.tenderPerson) {
				uni.showToast({
					title: '请选择投标编制人',
					icon: 'none'
				})
				return false
			}
			var params = this.basicForm
			params.itemList = this.getManagerPlanList // 业务列表
			erpOmcTenderEdit (params).then(res => {
				if (res.success) {
					this.$refs.uToast.show({
						message: '提交成功',
						type: 'success',
						complete () {
							_this.onAudit()
						}
					})
					this.isSubmit = true // 是否提交
				} else {
					this.$refs.uToast.show({
						message: res.message,
						type: 'error'
					})
				}
			})
		},
		
		onAudit() {
			 if (!this.isSubmit) {
			 	uni.showToast({
			 		title: '请完善表单后审核',
			 		icon: 'none'
			 	})
			 	return false
			 }
			var that = this
			uni.navigateTo({
				url: '/pages/synergy/erpOmcTenderList'+`?item=${encodeURIComponent(JSON.stringify(this.model).replace(/%/g, '%25'))}`,
				success: function(data) {
					// 通过eventChannel向被打开页面传送数据
					var params = {
						nodeObj: that.dataNodeObj,
						tabvalue: that.tabvalue
					}
					data.eventChannel.emit('sendMessage', params)
				},
				fail: function(err) {
					that.$refs.uToast.show({
						message: '请联系管理员配置',
						type: 'error'
					})
				}
			})
		}
		
	}
};
</script>

<style lang="scss" scoped>
@import url("@/assets/inputStyle.scss");
// 评测信息
.info-title{
	font-size: 28rpx;
	font-family: PingFangSC-Regular, PingFang SC;
	font-weight: 400;
	color: #171717;
	line-height: 40rpx;
	padding-bottom: 16rpx;
}

// 评测结果
.result-style{
	font-size: 24rpx;
	font-family: PingFangSC-Regular, PingFang SC;
	font-weight: 400;
	color: #B2B2B2;
}

.inforamtion{
	margin-top: 10rpx;
	padding: 10rpx;
	border-radius: 15rpx;
	box-shadow: 0px 4px 20px 0px rgba(0,0,0,0.1);
}
</style>